import request from '@/utils/request'

export function getUserFarms() {
  return request({
    url: '/api/farms/list',
    method: 'get'
  })
}

export function addFarm(data) {
  return request({
    url: '/api/farms/create',
    method: 'post',
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 获取待审核农场列表
export function getApplyFarms() {
  return request({
    url: '/api/farms/apply',
    method: 'get'
  })
}

// 更新农场状态
export function updateFarmStatus(farmId, status) {
  return request({
    url: '/api/farms/status',
    method: 'post',
    data: {
      farmId,
      status
    }
  })
}

// 审批农场申请
export function approveFarm(farmId, amount, farmUserId) {
  return request({
    url: `/api/farms/approve/${farmId}`,
    method: 'post',
    params: {
      amount: amount,
      farmUserId: farmUserId
    }
  })
}

// 拒绝农场申请
export function rejectFarm(farmId, farmUserId) {
  return request({
    url: `/api/farms/reject/${farmId}`,
    method: 'post',
    params: {
      farmUserId
    }
  })
}

// 获取农场详情
export function getFarmDetail(farmId, userId) {
  return request({
    url: `/api/farms/detail/${farmId}`,
    method: 'get',
    params: {
      userId
    }
  })
}

// 重新提交农场申请
export function reapplyFarm(farmId, userId) {
  return request({
    url: '/api/farms/reapply',
    method: 'post',
    params: {
      farmId,
      userId
    }
  })
}

// 更新农场信息
export function updateFarm(farmId, formData) {
  return request({
    url: `/api/farms/update/${farmId}`,
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
} 